home *** CD-ROM | disk | FTP | other *** search
- /* include file for hash searching */
-
-
- class hashtable
- { // private:
- typedef struct entry { char *key, *data; } ENTRY;
- unsigned prime(unsigned size); // generate prime number
- int hash(char *str); // hash function
- int hcreate(unsigned nel); // create hash table
- static ENTRY *hash_table; // pointer to hash table
- static unsigned num_elem; // max num table elements
- static unsigned count; // current table entry count
-
- public:
- typedef enum { fIND, ENTER, DELETE } ACTION;
- hashtable(unsigned size) // constructor
- {
- hcreate(size);
- }
- void hdestroy();
- // search for an item
- ENTRY *hsearch(ENTRY item, ACTION action);
- unsigned hcount(); // num items in table
- unsigned hsize(); // hash table size
- int hwrite(); // write hash table
- int hread(); // read hash table
- ~hashtable() { hdestroy(); } // destructor
- };
-